home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_28_airbrush tools.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  9.5 KB  |  126 lines

  1. global gVariable, gCast, gSize, gFirstColor, gAirbrushSize, gAirbrushShape, gAirbrushMask, myCurrentImage, myCurrentPreview
  2.  
  3. on toolAirbrush
  4.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  5.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  6.   myCurrentPreview = duplicate(member("preview", gCast).image)
  7.   repeat while the mouseDown
  8.     if gAirbrushShape = #rect then
  9.       if gAirbrushSize = 7 then
  10.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  11.         randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  12.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  13.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  14.         randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  15.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  16.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  17.         randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  18.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  19.       else
  20.         if gAirbrushSize = 5 then
  21.           randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  22.           randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  23.           myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  24.           randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  25.           randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  26.           myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  27.         else
  28.           if gAirbrushSize = 3 then
  29.             randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  30.             randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - (gAirbrushSize / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + (gAirbrushSize / 2))
  31.             myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  32.           end if
  33.         end if
  34.       end if
  35.     else
  36.       if gAirbrushSize = 7 then
  37.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 1, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1)
  38.         randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 3, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 3)
  39.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  40.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 3, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 3)
  41.         randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  42.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  43.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 2)
  44.         randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2)
  45.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  46.         randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 2)
  47.         randomY = random((the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 2)
  48.         myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  49.       else
  50.         if gAirbrushSize = 5 then
  51.           randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 1, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1)
  52.           randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 2, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 2)
  53.           myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  54.           randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 2)
  55.           randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  56.           myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  57.         else
  58.           if gAirbrushSize = 3 then
  59.             randomX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  60.             randomY = random(((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  61.             myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  62.             randomX = random(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 1, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1)
  63.             randomY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  64.             myCurrentImage.setPixel(randomX, randomY, gFirstColor)
  65.           end if
  66.         end if
  67.       end if
  68.     end if
  69.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  70.     sprite(8).rect = rect(the mouseH - (gAirbrushSize * gVariable / 2), the mouseV - (gAirbrushSize * gVariable / 2), the mouseH + (gAirbrushSize * gVariable / 2), the mouseV + (gAirbrushSize * gVariable / 2))
  71.     updateStage()
  72.     put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  73.     put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  74.     fnUpdatePreview()
  75.   end repeat
  76.   sprite(35).pState = 0
  77.   sendSprite(35, #setMember)
  78.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  79.   myCurrentImage = VOID
  80.   myCurrentPreview = VOID
  81.   put EMPTY into field "location status X"
  82.   put EMPTY into field "location status Y"
  83. end
  84.  
  85. on toolRGBAirbrush
  86.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  87.   coordinateList = []
  88.   coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
  89.   coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
  90.   member(gSize & "x" & gSize, gCast).image.copyPixels(member("1st Color", gCast).image, rect(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 4, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 4, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 5, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 5), rect(0, 0, 9, 9), [#blendLevel: 5, #maskImage: member(gAirbrushMask).image.createMask()])
  91.   sprite(8).rect = rect(the mouseH - (gAirbrushSize * gVariable / 2), the mouseV - (gAirbrushSize * gVariable / 2), the mouseH + (gAirbrushSize * gVariable / 2), the mouseV + (gAirbrushSize * gVariable / 2))
  92.   updateStage()
  93.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  94.   myCurrentPreview = duplicate(member("preview", gCast).image)
  95.   repeat while the mouseDown
  96.     if (getAt(coordinateList, 1) = ((the mouseH - sprite(1).left) * 2 / gVariable / 2)) and (getAt(coordinateList, 2) = ((the mouseV - sprite(1).top) * 2 / gVariable / 2)) then
  97.       nothing()
  98.     else
  99.       coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
  100.       coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
  101.       numSteps = float(sqrt(power(getAt(coordinateList, 1) - getAt(coordinateList, 3), 2) + power(getAt(coordinateList, 2) - getAt(coordinateList, 4), 2))) + 1
  102.       repeat with i = 1 to numSteps
  103.         l = (getAt(coordinateList, 1) * (numSteps - float(i)) / numSteps) + (getAt(coordinateList, 3) * (float(i) / numSteps))
  104.         t = (getAt(coordinateList, 2) * (numSteps - float(i)) / numSteps) + (getAt(coordinateList, 4) * (float(i) / numSteps))
  105.         myCurrentImage.copyPixels(member("1st Color", gCast).image, rect(l - 4, t - 4, l + 5, t + 5), rect(0, 0, 9, 9), [#blendLevel: 5, #maskImage: member(gAirbrushMask).image.createMask()])
  106.       end repeat
  107.       deleteAt(coordinateList, 1)
  108.       deleteAt(coordinateList, 1)
  109.       member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  110.       sprite(8).rect = rect(the mouseH - (gAirbrushSize * gVariable / 2), the mouseV - (gAirbrushSize * gVariable / 2), the mouseH + (gAirbrushSize * gVariable / 2), the mouseV + (gAirbrushSize * gVariable / 2))
  111.       updateStage()
  112.     end if
  113.     put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  114.     put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  115.     fnUpdatePreview()
  116.   end repeat
  117.   coordinateList = VOID
  118.   sprite(35).pState = 0
  119.   sendSprite(35, #setMember)
  120.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  121.   myCurrentImage = VOID
  122.   myCurrentPreview = VOID
  123.   put EMPTY into field "location status X"
  124.   put EMPTY into field "location status Y"
  125. end
  126.